/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.escuela.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.escuela.modelo.Materia;

/**
 *
 * @author Maq-8
 */
@Stateless
public class MateriaDao extends AbstractDao<Materia> implements MateriaDaoLocal {
    @PersistenceContext(unitName = "Escuela-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public MateriaDao() {
        super(Materia.class);
    }

    @Override
    public boolean findByDuplicity(Materia matter) {
        Query q = em.createNamedQuery("Materia.findByNombre");
        q.setParameter("nombre", matter.getNombre());
        return !q.getResultList().isEmpty();
    }
    
    
}
